home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Educ / Calc / MathPad 2.35.sit / XFuns / linfit.rsrc / TEXT_128_linfit().txt next >
Encoding:
Text File  |  1995-04-29  |  366 b   |  13 lines

  1. -- linfit(XYarray)
  2.  
  3. -- Fits data to a straight line using linear regression formula.
  4. -- linfit() returns the correlation coefficient.
  5. -- The fit parameters are returned in global variables 'slope' and 'intercept'.
  6.  
  7. XY={{3,2},{4,4},{4,5},{3,3.5},{2,2},{0,0},{5,4},{1,1},{3,2.5},{1,2}}
  8.  
  9. plot XY
  10. linfit(XY):0.897
  11. slope:0.866;   intercept:0.348
  12. plot slope*X + intercept
  13.